package org.hy.service.simple;

import org.apache.commons.lang.StringUtils;
import org.hy.domain.User;
import org.hy.persistence.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements IUserService{

	@Autowired
	private UserMapper userMapper;
	
	@Override
	public User verify(String username, String pwd) {
		boolean suc = false;
		User user = userMapper.findUserByEmail(username);
		suc = !StringUtils.isBlank(pwd) && StringUtils.equals(user.getPassword(), pwd);
		if(!suc)return null;
		return user;
	}

	@Override
	public void register(User user) {
		userMapper.insertUser(user);
	}

	@Override
	public User findUserById(int id) {
		return userMapper.findUserById(id);
	}

	
	
	
}
